package com.all.play.myrecycleviewheadandfooter;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.TextView;

import com.all.play.myrecycleviewheadandfooter.adapter.RvAdapter;
import com.all.play.myrecycleviewheadandfooter.view.MyRecycleView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private MyRecycleView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        recyclerView = (MyRecycleView) findViewById(R.id.rv);


        TextView headtextView = new TextView(this);
        ViewGroup.LayoutParams layoutParamshead = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
        );
        headtextView.setLayoutParams(layoutParamshead);
        headtextView.setText("头部");


        TextView footertextView = new TextView(this);
        ViewGroup.LayoutParams layoutParamsfooter = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
        );
        footertextView.setLayoutParams(layoutParamsfooter);
        footertextView.setText("尾部");


        recyclerView.addHeaderView(headtextView);
        recyclerView.addFooterView(footertextView);

        List<String> list=new ArrayList<>();
        for (int i=0;i<20;i++){
            list.add("hashiqi "+i);
        }
        Log.i("onBindViewHolder", "onBindViewHolder: "+list.size());
        RvAdapter rvAdapter = new RvAdapter(this, list);

        recyclerView.setAdapter(rvAdapter);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));


    }
}
